#define MAX_SIZE  101
#define STYLE '#'
#include "process.h"
void Flash_process(double total, double current){
	 char buffer[MAX_SIZE] = {'\0'};
	 const char* lable = "|/-\\";
	int len = strlen(lable);
	//计算要打出的符号数以及百分数
	double rata = (current* 100.0 / total);
    	int nums = (int)rata;
	//在buffer里填充符号
	memset(buffer, STYLE, nums);
	//回车打印符号及百分数
	printf("[%-100s] [%.1f%%] [%c]\r",buffer, rata, lable[nums % len]);
	//将其显示在屏幕上
	fflush(stdout);
	//将buffer清空
	memset(buffer, '\0', nums);

}
void Down_Load(){
	//定义下载速度以及下载进度
	double current = 0.0;
	double total = 100.0;
	//
	while(current <= total){
		//调用进度条函数
		Flash_process(total, current);
		usleep(50000);//50ms
		current+=1.0;					
	}

	printf("\n");
}
